package homework.homework_11.book;

import java.util.Objects;

/**
 * @author 朱
 * @date 2019042421:53
 * 数据库中创建一张图书表book，包括图书编号、图书名称、出版社、作者、价格字段。
 */
public class Book {
    private String number;
    private String name;
    private String press;
    private String writer;
    private double price;

    public Book() {
    }


    public Book(String name, String press, String writer, double price) {
        this.name = name;
        this.press = press;
        this.writer = writer;
        this.price = price;
    }

    public Book(String number, String name, String press, String writer, double price) {
        this.number = number;
        this.name = name;
        this.press = press;
        this.writer = writer;
        this.price = price;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPress() {
        return press;
    }

    public void setPress(String press) {
        this.press = press;
    }

    public String getWriter() {
        return writer;
    }

    public void setWriter(String writer) {
        this.writer = writer;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Book book = (Book) o;
        return Double.compare(book.price, price) == 0 &&
                Objects.equals(number, book.number) &&
                Objects.equals(name, book.name) &&
                Objects.equals(press, book.press) &&
                Objects.equals(writer, book.writer);
    }

    @Override
    public int hashCode() {
        return Objects.hash(number, name, press, writer, price);
    }

    @Override
    public String toString() {
        return "Book{" +
                "number='" + number + '\'' +
                ", name='" + name + '\'' +
                ", press='" + press + '\'' +
                ", writer='" + writer + '\'' +
                ", price=" + price +
                '}';
    }
}
